/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interceptor;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import constantes.FonolConstantes;
import fonol.entidades.Usuarios;
import java.util.Map;

/**
 *
 * @author fredfred2
 */
public class AutenticationInterceptor implements Interceptor {

    public void destroy() {
    }

    public void init() {
    }

    public String intercept(ActionInvocation actionInvocation) throws Exception {
        Map session = actionInvocation.getInvocationContext().getSession();

        Usuarios user = (Usuarios) session.get(FonolConstantes.USER);
        if (user == null) {
            
            return Action.LOGIN;
        } else {

            return actionInvocation.invoke();

        }

    }
}


